﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using Magic;

namespace JCore.LoLProfiler_Test.Classes
{
    public class LoLMemoryReader
    {
        BlackMagic test = new BlackMagic();
        private Process p;
        private uint BasePointer, step1, step2;
        /*
            // Gold
            uint step1 = BasePointer + 0xF4;
            uint step2 = test.ReadUInt(step1) + 0xC;
            MessageBox.Show(test.ReadUInt(step2).ToString());

            // Mana
            step1 = BasePointer + 0xF8;
            step2 = test.ReadUInt(step1) + 0x68;
            MessageBox.Show(test.ReadUInt(step2).ToString());

            // Health
            step1 = BasePointer + 0xF8;
            step2 = test.ReadUInt(step1) + 0x58;
            MessageBox.Show(test.ReadUInt(step2).ToString());

            // AD
            step1 = BasePointer + 0xF4;
            step2 = test.ReadUInt(step1) + 0x24;
            MessageBox.Show(test.ReadUInt(step2).ToString());

            // Movement Speed
            step1 = BasePointer + 0xF4;
            step2 = test.ReadUInt(step1) + 0x34;
            MessageBox.Show(test.ReadUInt(step2).ToString());
          
            // Max HP
            F8 + 5C
          
            // Max MP
            
        */

        public void InitializeMemoryReader()
        {
            test.OpenProcessAndThread(SProcess.GetProcessFromProcessName("League of Legends"));
            p = Process.GetProcessById(test.ProcessId);
            BasePointer = test.ReadUInt(0x01D3D2A0);
        }

        public int getCurrentHp
        {
            get
            {
                step1 = BasePointer + 0xF8;
                step2 = test.ReadUInt(step1) + 0x58;
                return test.ReadInt(step2);
            }
        }

        public int getCurrentMana
        {
            get
            {
                step1 = BasePointer + 0xF8;
                step2 = test.ReadUInt(step1) + 0x68;
                return test.ReadInt(step2);
            }
        }

        public int getMaxHp
        {
            get
            {
                step1 = BasePointer + 0xF8;
                step2 = test.ReadUInt(step1) + 0x5C;
                return test.ReadInt(step2);
            }
        }

        public int getMaxMana
        {
            get
            {
                step1 = BasePointer + 0xF8;
                step2 = test.ReadUInt(step1) + 0x6C;
                return test.ReadInt(step2);
            }
        }

        public int getAttackDamage
        {
            get
            {
                step1 = BasePointer + 0xF4;
                step2 = test.ReadUInt(step1) + 0x24;
                return test.ReadInt(step2);
            }
        }

        public int getCurrentGold
        {
            get
            {
                step1 = BasePointer + 0xF4;
                step2 = test.ReadUInt(step1) + 0xC;
                return test.ReadInt(step2);
            }
        }

        public int getMovementSpeed
        {
            get
            {
                step1 = BasePointer + 0xF4;
                step2 = test.ReadUInt(step1) + 0x34;
                return test.ReadInt(step2);
            }
        }

        public int getArmor
        {
            get
            {
                step1 = BasePointer + 0xF4;
                step2 = test.ReadUInt(step1) + 0x20;
                return test.ReadInt(step2);
            }
        }

        public int getMagicResist
        {
            get
            {
                step1 = BasePointer + 0xF4;
                step2 = test.ReadUInt(step1) + 0x30;
                return test.ReadInt(step2);
            }
        }
    }
}
